using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;

namespace Tomahawk.Runtime.Screen.Controls
{

    /// <summary>
    /// This class is an user interface control that renders a shadowed text
    /// </summary>
    public class TextTile : ScreenControl
    {
        private string fontName = @"Tomahawk.Content\Debug\DebugWriter";
        private bool renderShadow = true;
        private string caption = "TEST";

        protected Color textColor = Color.White;
        protected Color shadowColor = Color.Black;
        protected SpriteFont font;
        protected Point shadowDisplacement = new Point(2, 2);

        #region "Public Properties"

        public string FontName
        {
            get { return fontName; }
            set { fontName = value; }
        }

        public Color TextColor
        {
            get { return textColor; }
            set { textColor = value; }
        }

        public Color ShadowColor
        {
            get { return shadowColor; }
            set { shadowColor = value; }
        }

        public bool RenderShadow
        {
            get { return renderShadow; }
            set { renderShadow = value; }
        }

        public Point ShadowDisplacement
        {
            get { return this.shadowDisplacement; }
            set { this.shadowDisplacement = value; }
        }

        #endregion

        public string Caption
        {
            get { return caption; }
            set { caption = value; }
        }

        /// <summary>
        /// Renders the text into the spriteBatch
        /// </summary>
        protected override void OnRender(GraphicsDevice device, SpriteBatch spriteBatch)
        {
            Rectangle rect = this.Rect;
            spriteBatch.DrawString(font, caption, new Microsoft.Xna.Framework.Vector2(rect.Left + this.shadowDisplacement.X, rect.Top + this.shadowDisplacement.Y), this.shadowColor);
            spriteBatch.DrawString(font, caption, new Microsoft.Xna.Framework.Vector2(rect.Left, rect.Top), this.textColor);
        }

        /// <summary>
        /// Assets loading
        /// </summary>
        protected override void OnLoadGraphicContent(GraphicsDevice myDevice, ContentManager myLoader)
        {
            font = myLoader.Load<SpriteFont>(this.fontName);
        }

    }

}
